﻿Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Seuss.EnterpriseLibrary.DataAccess
Imports Seuss.EnterpriseLibrary.BusinessLogic
Imports System.Web
Imports System.Data

Partial Class Consulta_AL_CursoActual_Foro
    Inherits System.Web.UI.Page
    Dim nCurGruCodigo As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.QueryString("nCurGruCodigo") Is Nothing Or Request.QueryString("nCurGruCodigo") Is String.Empty Then
            If Session("nCurGruCodigo") Is Nothing Or Session("nCurGruCodigo") Is String.Empty Then
                Response.Redirect("AL_InfoAcad_CA.aspx")
            Else
                nCurGruCodigo = Session("nCurGruCodigo")
            End If
        Else
            Session("nCurGruCodigo") = Request.QueryString("nCurGruCodigo")
            nCurGruCodigo = Request.QueryString("nCurGruCodigo")
        End If
        Response.Expires = -1
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("cache-control", "private")
        Response.CacheControl = "no-cache"
        lnkRegresar_3.HRef = "./AL_CursoActual.aspx?nCurGruCodigo=" + nCurGruCodigo
        lnkRegresar_4.HRef = "./AL_CursoActual.aspx?nCurGruCodigo=" + nCurGruCodigo

        If Not Page.IsPostBack Then
            CargaForos()
            Using Seguridad As New BLL_Administracion
                Seguridad.Set_Transaccion_Insert(Nothing, 100401, IdentityUser.UserCode, My.Request.UserHostAddress.ToString, CrearXMLTransaccion("Consulta Pagina Movil", "/Pagina|" + My.Request.Url.Segments(My.Request.Url.Segments.Length - 1).ToString))
            End Using
        End If
    End Sub

    Private Sub CargaForos()
        Dim DivPrincipal As New StringBuilder
        Dim ldrforos As New List(Of IDataReader)
        Dim StrForos As String = ""
        Dim StrForosDisp As String = ""
        Using ObjPool As New PoolDbCommand()
            Dim Objgrupo As New DAL_Kiosco(ObjPool.Database)
            ObjPool.AddDbCommand(Objgrupo.Get_ForoCampus_By_nCurGruCodigo_nForoPadre_nForoPrincipal(nCurGruCodigo, "0", "0", 1), PoolDbCommand.PoolDbCommandResultType.Query)
            ObjPool.Pooling(Nothing, ldrforos, True)
        End Using
        'DivPrincipal.Append("<h5>" & Session("cursoactual") & "</h5>")
        DivPrincipal.Append("<div class=""listview"">")
        StrForos = StrForos + "<ul>"
        StrForos = StrForos + "<li><p>TEMAS</p></li>"
        'DivPrincipal.Append("<ul data-role=""listview"">")
        'DivPrincipal.Append("<li><p>TEMAS</p><span class=""ui-li-count"">Respuestas</span></li>")
        While ldrforos(0).Read
            StrForosDisp = StrForosDisp + "<li><a href=""AL_CursoActual_ForoRes.aspx?nCurGruCodigo=" & nCurGruCodigo & "&nivelforo=" & ldrforos(0).Item("nForo") & """><p style=""white-space:normal; text-align:justify"">" & ldrforos(0).Item("tForoDesc") & "</p><p2>Total respuestas:  </p2><span2>" & ldrforos(0).Item("RespuestasTema") & "</span2></a></li>"

            'DivPrincipal.Append("<li><a href=""AL_CursoActual_ForoRes.aspx?nCurGruCodigo=" & nCurGruCodigo & "&nivelforo=" & ldrforos(0).Item("nForo") & """><p style=""white-space:normal; text-align:justify"">" & ldrforos(0).Item("tForoDesc") & "</p><span class=""ui-li-count"">" & ldrforos(0).Item("RespuestasTema") & "</span></a></li>")
        End While
        If StrForosDisp.ToString = "" Then
            DivPrincipal.Append("<p><strong>NO HAY FOROS DISPONIBLES</strong></p>")
        Else
            DivPrincipal.Append(StrForos)
            DivPrincipal.Append(StrForosDisp)
            DivPrincipal.Append("</ul></div>")
        End If
        lblcontenido.Text = DivPrincipal.ToString

        ldrforos(0).Close()
        ldrforos(0) = Nothing
    End Sub

End Class